package com.rpp.study.hystrix;

import com.rpp.study.base.LagouResponse;
import com.rpp.study.feign.FeignUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author rpp
 * @Date 2020/8/28 10:39 下午
 */
@Slf4j
@Component
public class HystrixUserFactory implements FallbackFactory<FeignUser> {
    @Override
    public FeignUser create(Throwable throwable) {
        log.error("触发熔断：", throwable);
        return new FeignUser() {
            @Override
            public LagouResponse<Boolean> register(String email, String password, String code) {
                return LagouResponse.error();
            }

            @Override
            public LagouResponse<Boolean> isRegistered(String email) {
                return LagouResponse.error();
            }

            @Override
            public LagouResponse<String> login(String email, String password) {
                return LagouResponse.error();
            }

            @Override
            public LagouResponse<String> info(String token) {
                return LagouResponse.error();
            }
        };
    }
}
